;;;Rerotate a selection set of entities to be horiz to the view.
;;;
;;;	AUTHOR: HENRY C. FRANCIS
;;;		425 N. ASHE ST.
;;;		SOUTHERN PINES, NC 28387
;;;              
;;;		All rights reserved without prejudice.
;;;	Copyright:	8-31-95
;;;	Edited:		9-16-15
;;;
;;;	Added option to sepcifiy rotation angle by points
;;;
(defun c:rerot (/)
(if ukword nil (load "ukword" "\nFile UKWORD.LSP not loaded! "))
(setq rotopt (ukword 1 "Line Horizontal" "Rotate to [Line/Horizontal/Points]?" (IF rotopt rotopt "Horizontal")))
(setq ents (entsel "\nSelect rotated entity. "))
(setq ent (entget (car ents)))
(if (eq (cdr (assoc 0 ent)) "MULTILEADER")
  (setq currot (angtos (- 0 (cdr(assoc 42 ent)))0 6))
  (setq currot (angtos (- 0 (cdr(assoc 50 ent)))0 6))
)
(setq ss1 (ssget))
(if upoint nil (load "upoint.lsp" "\nFile UPOINT.LSP not loaded! "))
(setq pt1 (upoint 1 "" "Origin point for rotation" nil nil))
(COND
  ((eq rotopt "Line")
   (setq line-ss (ssget '((0 . "LINE"))))
   (setq line-ent (entget (ssname line-ss 0)))
   (setq cv_twist (angtos (-(angle (cdr (assoc 10 line-ent))(cdr (assoc 11 line-ent))))0 6))
  )
  ((eq rotopt "Points")
   (setq cv_twist (angtos (-(angle
                              (SETQ line-pt01 (upoint 1 "" "Select first point" nil nil))
                              (SETQ line-pt02 (upoint 1 "" "Select second point" nil line-pt01))
                            )
                          )
                          0 6
                  )
   ))
  ((eq rotopt "Horizontal")
   (setq cv_twist (angtos (getvar"viewtwist")0 6)))
)
(setq rot (+(- 0 (atof cv_twist))(atof currot)))
(command ".rotate" ss1 "" pt1 rot)
);defun
